package easy;

public class Solution_1566 {

    public boolean containsPattern(int[] arr, int m, int k) {
        int length = arr.length - m * k;
        for (int i = 0; i <= length; i++) {
            boolean flag = true;
            for (int j = i; j < m + i; j++) {
                for (int p = j + m, q = 1; q < k; p += m, q++) {
                    if (arr[p] != arr[j]) {
                        flag = false;
                        break;
                    }
                }
                if (!flag) {
                    break;
                }
            }
            if (flag) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        Solution_1566 model = new Solution_1566();
        System.out.println(model.containsPattern(new int[]{1, 2, 4, 4, 4, 4}, 1, 3));
        System.out.println(model.containsPattern(new int[]{1, 2, 1, 2, 1, 1, 1, 3}, 2, 2));
        System.out.println(model.containsPattern(new int[]{1, 2, 1, 2, 1, 3}, 2, 3));
        System.out.println(model.containsPattern(new int[]{1, 2, 3, 1, 2}, 2, 2));
        System.out.println(model.containsPattern(new int[]{2, 2, 2, 2}, 2, 3));
        System.out.println(model.containsPattern(new int[]{2, 2, 1, 2, 2, 1, 1, 1, 2, 1}, 2, 2));
    }
}
